﻿/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2018. All rights reserved.
 * Description:
 * Author: 张拓 00345863
 * Create: 2020-07-28
 * Notes: 无
 */
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QTranslator>
#include <QLocale>
#include <QMessageBox>
#include "qtsingleapplication.h"
#include <iostream>
#include "mainwindow.h"
#include "logger.h"
#include "IShareServiceController.h"
#include "ShareEventHandler.h"



void init_and_print_values()
{
  std::cout <<"-------------print values-------------- ";
}



int main(int argc, char *argv[])
{
    /* 单例进程 */
   QtSingleApplication instance(argc, argv);

    /* 重定向日志输出到文件-注册回调 */
    qInstallMessageHandler(messageOutput);
    // 加载QSS样式表
    QFile qss(":/qss/IdeaShare.qss");
    if (qss.open(QFile::ReadOnly)) {
        QString style = QLatin1String(qss.readAll());
         instance.setStyleSheet(style);
         qss.close();
    }


//#if defined(IDEASHAREKEY)
//    bool ret = ideasharesdk::ideasharesdk_init(ideasharesdk::IDEASHAREKEY_SDK);
//#else
//    bool ret = ideasharesdk::ideasharesdk_init(ideasharesdk::IDEASHARE_SDK);
//#endif
//    if (!ret) {
//        qDebug() << "ideasharesdk init error";
//        return 0;
//    }
    /* 输出 ideasharesdk 相关变量 */
    init_and_print_values();
    /* 加载翻译文件 */
    QLocale locale;
    QTranslator translator;
    translator.load(":/qm/IdeaShare_zh_CN.qm");
    instance.installTranslator(&translator);

    qRegisterMetaType<uint32_t>("uint32_t");

    MainWindow w;
    instance.setActivationWindow(&w);
    w.show();
    int r = instance.exec();
    qDebug() << "------------------ main exit -----------------  return value :" << r;
    return r;
}
